<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-MELANGE.
 *
 * PHP-MELANGE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-MELANGE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-MELANGE; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-melange
 * @subpackage  cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */
?>
<?=$this->header()?>


    <?=$this->menu("menus")?>


    <h1><?=$this->message("label.header", _Menu::BUNDLE)?></h1>


    <? /* Breadcrums route */ ?>
    <?=$this->route(
        array(
            array(
                "name"=>$this->message("label.header", _Menu::BUNDLE),
                "href"=>"menu/index"
            ),
            array(
                "name"=>($this->menuForm->getMenu()->getMenuId() > 0 ?
                    $this->message("route.edit", _Core::BUNDLE)." \"".$this->menuForm->getMenu()->getName()."\"" :
                    $this->message("route.new", _Core::BUNDLE) . " " . $this->message("label.item", _Menu::BUNDLE))
            )
        )
    )?>


    <? /* Show error messages */ ?>
    <?=$this->errors(null, _Menu::BUNDLE)?>


    <form id="<?=get_class($this->menuForm)?>"
          action="menu/save"
          method="post"
          enctype="multipart/form-data"
          class="uniForm">

        <div><input type="hidden" name="menu->menuId" value="<?=$this->menuForm->getMenu()->getMenuId()?>" /></div>

        <fieldset>

            <legend><?=$this->message("label.required", _Core::BUNDLE)?></legend>

            <table cellspacing="0" cellpadding="0" class="form">
            <tr class="ctrl<?=$this->error("menu->name")?>">
                <th><label for="name"><?=$this->message("prompt.name", _Menu::BUNDLE)?></label></th>
                <th class="required"><em>*</em></th>
                <td>
                    <input name="menu->name"
                           id="name"
                           value="<?=$this->menuForm->getMenu()->getName()?>"
                           maxlength="30"
                           type="text"
                           class="textInput" />
                    <p class="hint">Note: this name is for reference only and will not be visible on the website.</p>
                </td>
            </tr>

            <? /* Hide i18n if disabled */ ?>
            <? if($this->param(_Core::I18N)): ?>
                <tr class="ctrl<?=$this->error("menu->languageCode")?>">
                    <th><label for="language"><?=$this->message("title.language", _Core::BUNDLE)?></label></th>
                    <th class="required"><em>*</em></th>
                    <td>
                        <select name="menu->languageCode" id="language" class="textInput">
                            <? foreach($this->languages(false, true) as $language): ?>
                                <option value="<?=$language->getCode()?>"<?=$this->menuForm->getMenu()->getLanguageCode() ==
                                    $language->getCode() ? " selected=\"selected\"" : ""?>><?=$language->getName()?></option>
                            <? endforeach; ?>
                        </select>
                    </td>
                </tr>
            <? endif; ?>

            </table>

        </fieldset>

        <div class="buttons">

            <input type="button"
                   onclick="to('menu/index')"
                   value="<?=$this->message("button.cancel", _Core::BUNDLE)?>"
                   class="button" />
            <input type="submit"
                   value="<?=$this->message("button.submit", _Core::BUNDLE)?>"
                   class="button" />

        </div>

    </form>
    
    <?=$this->focus(get_class($this->menuForm), "menu->name")?>

<?=$this->footer()?>